package com.heima.admin.job;

import com.heima.admin.feign.WemediaFeign;
import com.heima.admin.service.WemediaNewsAutoScanService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Slf4j
public class WeMediaNewsAutoScanJob {
    @Autowired
    private WemediaNewsAutoScanService wemediaNewsAutoScanService;
    @Autowired
    private WemediaFeign wemediaFeign;

    //每天0点执行一次
    @XxlJob("wemediaAutoScanJob")
    public ReturnT<String>hello(String param){
        log.info("自媒体文章审核调度任务开始执行....");
        List<Integer> list = wemediaFeign.findRelease();
        if(null!=list && !list.isEmpty()){
            for (Integer id : list) {
                wemediaNewsAutoScanService.autoScanByMediaNewsId(id);
            }
        }
        log.info("自媒体文章审核调度任务执行结束。");
        return ReturnT.SUCCESS;
    }
}
